package model

import (
	"time"

	"gorm.io/gorm"
)

// UserOperationLog 用户操作日志模型
type UserOperationLog struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	UserID    uint           `gorm:"type:int;not null;index:idx_user_id;comment:用户ID" json:"userId"`
	Title     string         `gorm:"type:varchar(200);comment:操作标题" json:"title"`
	URL       string         `gorm:"type:varchar(500);comment:操作URL" json:"url"`
	IP        string         `gorm:"type:varchar(50);comment:IP地址" json:"ip"`
	Method    string         `gorm:"type:varchar(10);comment:HTTP方法" json:"method"`
	UserAgent string         `gorm:"type:varchar(500);comment:User-Agent" json:"userAgent"`
	CreatedAt time.Time      `gorm:"index:idx_created_at;comment:操作时间" json:"createdAt"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`

	// 关联
	User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
}

// TableName 指定表名
func (UserOperationLog) TableName() string {
	return "sys_user_operation_log"
}
